package cn.zane.mybatis.session;

import cn.zane.mybatis.builder.xml.XMLConfigBuilder;
import cn.zane.mybatis.session.defaults.DefaultSqlSessionFactory;

import java.io.Reader;

/**
 * @author zane
 * @date 2025/01/20
 * @Description SqlSession工厂建造者类。SqlSessionFactoryBuilder是作为整个Mybatis的入口类，通过指定解析XML的IO，引导整个流程的启动。
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(Reader reader) {
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(reader);
        return build(xmlConfigBuilder.parse());
    }

    public SqlSessionFactory build(Configuration config) {
        return new DefaultSqlSessionFactory(config);
    }
}
